home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / ExtUtils / Miniperl.pm < prev    next >
Text File  |  1999-01-25  |  4KB  |  172 lines

  1. # This File keeps the contents of miniperlmain.c.
  2. #
  3. # It was generated automatically by minimod.PL from the contents
  4. # of miniperlmain.c. Don't edit this file!
  5. #
  6. #       ANY CHANGES MADE HERE WILL BE LOST! 
  7. #
  8.  
  9.  
  10. package ExtUtils::Miniperl;
  11. require Exporter;
  12. @ISA = qw(Exporter);
  13. @EXPORT = qw(&writemain);
  14.  
  15. $head= <<'EOF!HEAD';
  16. /*
  17.  * "The Road goes ever on and on, down from the door where it began."
  18.  */
  19.  
  20. #ifdef OEMVS
  21. #pragma runopts(HEAP(1M,32K,ANYWHERE,KEEP,8K,4K))
  22. #endif
  23.  
  24.  
  25. #include "EXTERN.h"
  26. #include "perl.h"
  27.  
  28. static void xs_init _((void));
  29. static PerlInterpreter *my_perl;
  30.  
  31. int
  32. main(int argc, char **argv, char **env)
  33. {
  34.     int exitstatus;
  35.  
  36. #ifdef PERL_GLOBAL_STRUCT
  37. #define PERLVAR(var,type) /**/
  38. #define PERLVARI(var,type,init) PL_Vars.var = init;
  39. #define PERLVARIC(var,type,init) PL_Vars.var = init;
  40. #include "perlvars.h"
  41. #undef PERLVAR
  42. #undef PERLVARI
  43. #undef PERLVARIC
  44. #endif
  45.  
  46.     PERL_SYS_INIT(&argc,&argv);
  47.  
  48.     perl_init_i18nl10n(1);
  49.  
  50.     if (!PL_do_undump) {
  51.     my_perl = perl_alloc();
  52.     if (!my_perl)
  53.         exit(1);
  54.     perl_construct( my_perl );
  55.     PL_perl_destruct_level = 0;
  56.     }
  57.  
  58.     exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
  59.     if (!exitstatus) {
  60.     exitstatus = perl_run( my_perl );
  61.     }
  62.  
  63.     perl_destruct( my_perl );
  64.     perl_free( my_perl );
  65.  
  66.     PERL_SYS_TERM();
  67.  
  68.     exit( exitstatus );
  69.     return exitstatus;
  70. }
  71.  
  72. /* Register any extra external extensions */
  73.  
  74. EOF!HEAD
  75. $tail=<<'EOF!TAIL';
  76.  
  77. static void
  78. xs_init(void)
  79. {
  80. }
  81. EOF!TAIL
  82.  
  83. sub writemain{
  84.     my(@exts) = @_;
  85.  
  86.     my($pname);
  87.     my($dl) = canon('/','DynaLoader');
  88.     print $head;
  89.  
  90.     foreach $_ (@exts){
  91.     my($pname) = canon('/', $_);
  92.     my($mname, $cname);
  93.     ($mname = $pname) =~ s!/!::!g;
  94.     ($cname = $pname) =~ s!/!__!g;
  95.     print "EXTERN_C void boot_${cname} _((CV* cv));\n";
  96.     }
  97.  
  98.     my ($tail1,$tail2) = ( $tail =~ /\A(.*\n)(\s*\}.*)\Z/s );
  99.     print $tail1;
  100.  
  101.     print "\tchar *file = __FILE__;\n";
  102.     print "\tdXSUB_SYS;\n" if $] > 5.002;
  103.  
  104.     foreach $_ (@exts){
  105.     my($pname) = canon('/', $_);
  106.     my($mname, $cname, $ccode);
  107.     ($mname = $pname) =~ s!/!::!g;
  108.     ($cname = $pname) =~ s!/!__!g;
  109.     print "\t{\n";
  110.     if ($pname eq $dl){
  111.         # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  112.         # boot_DynaLoader is called directly in DynaLoader.pm
  113.         $ccode = "\t/* DynaLoader is a special case */\n
  114. \tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
  115.         print $ccode unless $SEEN{$ccode}++;
  116.     } else {
  117.         $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
  118.         print $ccode unless $SEEN{$ccode}++;
  119.     }
  120.     print "\t}\n";
  121.     }
  122.     print $tail2;
  123. }
  124.  
  125. sub canon{
  126.     my($as, @ext) = @_;
  127.     foreach(@ext){
  128.         # might be X::Y or lib/auto/X/Y/Y.a
  129.         next if s!::!/!g;
  130.         s:^(lib|ext)/(auto/)?::;
  131.         s:/\w+\.\w+$::;
  132.     }
  133.     grep(s:/:$as:, @ext) if ($as ne '/');
  134.     @ext;
  135. }
  136.  
  137. 1;
  138. __END__
  139.  
  140. =head1 NAME
  141.  
  142. ExtUtils::Miniperl, writemain - write the C code for perlmain.c
  143.  
  144. =head1 SYNOPSIS
  145.  
  146. C<use ExtUtils::Miniperl;>
  147.  
  148. C<writemain(@directories);>
  149.  
  150. =head1 DESCRIPTION
  151.  
  152. This whole module is written when perl itself is built from a script
  153. called minimod.PL. In case you want to patch it, please patch
  154. minimod.PL in the perl distribution instead.
  155.  
  156. writemain() takes an argument list of directories containing archive
  157. libraries that relate to perl modules and should be linked into a new
  158. perl binary. It writes to STDOUT a corresponding perlmain.c file that
  159. is a plain C file containing all the bootstrap code to make the
  160. modules associated with the libraries available from within perl.
  161.  
  162. The typical usage is from within a Makefile generated by
  163. ExtUtils::MakeMaker. So under normal circumstances you won't have to
  164. deal with this module directly.
  165.  
  166. =head1 SEE ALSO
  167.  
  168. L<ExtUtils::MakeMaker>
  169.  
  170. =cut
  171.  
  172.